#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
User: lyj
DateTime: 2012-05-20 14:04:00

"""

__author__ = 'lyj'



from demos.rabbitmq.settings import amqp_host, amqp_port
import pika
import time


connection = pika.BlockingConnection(pika.ConnectionParameters(
    host=amqp_host, port=amqp_port))
channel = connection.channel()

channel.queue_declare(queue="test", durable=True,
    exclusive=False, auto_delete=False)

print ' [*] Waiting for messages. To exit press CTRL+C'

def callback(ch, method, properties, body):
    print " [x] Received %r" % (body,)
    time.sleep(10)
    print " [x] End"

channel.basic_consume(callback,
    queue='test',
    no_ack=True)

channel.start_consuming()